<template>
  <div>
    <el-dialog class="app-container" title="入库采购产品" width="800px" :visible.sync="visible" top="5vh" append-to-body>
      <el-table  :data="stockList" ref="select" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column type="index" width="55" align="center" label="序号" />
        <el-table-column label="物品名称" align="center" prop="productName" />
        <el-table-column label="物品类型" align="center" prop="productType" />
        <el-table-column label="数量" align="center" prop="numbers" />
        <el-table-column label="单价" align="center" prop="price" />
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>

    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "enterpriseProduct",
  props:{stockList:Array},
  data(){
    return {
      visible:false,
      productList:[]
    }
  },
  methods:{
    show(){
      this.visible = true;
    },
    submitForm(){
      this.visible=false
      this.$emit('showEnterprise',this.productList)
      this.$refs.select.clearSelection()
    },
    cancel(){
      this.productList=[]
      this.$refs.select.clearSelection()
      this.visible=false
    },
    handleSelectionChange(value){
      if(value.length>0){
        this.productList=value[0]
        if (value.length > 1) {
          this.$refs.select.clearSelection();
          this.$refs.select.toggleRowSelection(value.pop());
        }
      }
    },
  }
}
</script>

<style scoped>

</style>
